import constant from "./constant"
/**
 * 存储变量名
 */
const storage_prefix = "flower_sea"

export const set = (key: string | number , value: any) :void =>{
    if(constant.hasOwnProperty(key)){
        let tmp = uni.getStorageSync(storage_prefix)
        tmp = tmp ? tmp : {}
        tmp[key] = value
        uni.setStorageSync(storage_prefix, tmp)
    }

}

export const get = (key: string | number) :any =>{
    let storageData = uni.getStorageSync(storage_prefix) || {}
    return storageData[key] || ""

}

export const remove = (key : string | number) :void =>{
    let storageData = uni.getStorageSync(storage_prefix) || {}
    delete storageData[key]
    uni.setStorageSync(storage_prefix, storageData)
}

export const clean = () :void => {
    uni.removeStorageSync(storage_prefix)
}